package template.method;

import java.util.Date;

/**
 * @author ZLL
 * @date create in 2018/05/10
 */
public abstract class Worker {

    protected  String name;


    public Worker(String name) {
        this.name = name;
    }

    public boolean isNeedPrintTime(){
        return false;
    }


    public final void workOneDay(){
        System.out.println("------------work start-------------");

        this.entryCompany();

        this.computerOn();

        this.work();

        this.computerOff();

        this.leaveCompany();

        System.out.println("-------------work end-----------------------");
    }


    public void  entryCompany(){
        System.out.println(name +"进入公司。。。");
    }

    public void leaveCompany(){

        if(isNeedPrintTime()){
            System.out.print(new Date().toLocaleString()+"===>");
        }
        System.out.println(name + "离开公司。。。");
    }

    public void computerOn(){
        System.out.println(name + "打开电脑。。。");
    }

    public void computerOff(){
        System.out.println(name + "关闭 电脑。。。");
    }

    public abstract void work();

}
